//
//  BMIVc.swift
//  GjCup
//
//  Created by abc on 2024/4/8.
//

import UIKit

class BMIVc: UIViewController {

    @IBOutlet weak var hTf: UITextField!
    
    @IBOutlet weak var wTf: UITextField!
    
    @IBOutlet weak var stratBtn: UIButton!{
        didSet{
            stratBtn.layer.cornerRadius = 4
        }
    }
    var bmi = 1.0
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    @IBAction func startAC(_ sender: UIButton) {
        let height = Float(hTf.text ?? "") ?? 0
        let weight = Float(wTf.text ?? "") ?? 0
        if height == 0 || weight == 0 {
            UIAlertController.ok_alert("请输入身高/体重", self)
            
            return
        }
        
        bmi = Double(weight / height / height)
        performSegue(withIdentifier: "BMIToDetail", sender: self)
    }
    
    
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
        if segue.identifier == "BMIToDetail" {
            let vc = segue.destination as! BMIDetailVc
            vc.bmi = bmi
        }
    }
    

}
